import { ChunlianChItem } from "./ChunlianChItem";
import { ChunlianWordItem } from "./ChunlianWordItem";
type int = number;
//class ChunlianWordList
    
    export  class ChunlianWordList /* flash.display.Sprite */
    {
        constructor(arg1: int=8, arg2: Boolean=false)
        {
            
            this.doubleClickEnabled = true;
            this.mouseEnabled = false;
            this._enableNum = arg1;
            this._isEnableTip = arg2;
            this.init();
            return;
        }

        public set enableNum(arg1: int)
        {
            var loc1=null;
            this._enableNum = arg1;
            var loc2=0;
            while (loc2 < this._wordItems.length) 
            {
                loc1 = this._wordItems[loc2];
                loc1.isEnable = loc2 < this._enableNum;
                ++loc2;
            }
            return;
        }

        public updateByChs(arg1: string): void
        {
            var loc1=null;
            var loc2=0;
            if (arg1 && !(arg1 == "")) 
            {
                loc2 = 0;
                while (loc2 < arg1.length) 
                {
                    loc1 = this._wordItems[loc2];
                    loc1.word = arg1.substr(loc2, 1);
                    ++loc2;
                }
            }
            return;
        }

        public clearWords(): void
        {
            var loc1=null;
            var loc2=0;
            while (loc2 < this._wordItems.length) 
            {
                loc1 = this._wordItems[loc2];
                loc1.word = "";
                ++loc2;
            }
            return;
        }

        public setWordToBlank(arg1: ChunlianChItem): Boolean
        {
            var loc1=null;
            var loc2=0;
            while (loc2 < this._enableNum) 
            {
                loc1 = this._wordItems[loc2];
                if (loc1.word == null || loc1.word == "") 
                {
                    loc1.word = arg1.word;
                    loc1.index = arg1.index;
                    return true;
                }
                ++loc2;
            }
            return false;
        }

        public getWords(): string
        {
            var loc2=null;
            var loc1="";
            var loc3=0;
            while (loc3 < this._enableNum) 
            {
                loc2 = this._wordItems[loc3];
                loc1 = loc1 + loc2.word;
                ++loc3;
            }
            return loc1;
        }

        /* internal  */init(): void
        {
            var loc1=null;
            this._wordItems = new Array<any>();
            var loc2=0;
            while (loc2 < 8) 
            {
                loc1 = new ChunlianWordItem(this._isEnableTip);
                loc1.y = loc2 * 44;
                loc1.doubleClickEnabled = true;
                this.addChild(loc1);
                loc1.isEnable = loc2 < this._enableNum;
                this._wordItems.push(loc1);
                ++loc2;
            }
            return;
        }

        /* internal */ /* var */_wordItems: Array<any>;

        /* internal */ /* var */_enableNum: int;

        /* internal */ /* var */_isEnableTip: Boolean;
    }
